using System;
using System.Threading.Tasks;
using JlPay.Sdk.Core;
using JlPay.Sdk.Models.Cashier;

namespace JlPay.Sdk.Services.Cashier
{
    /// <summary>
    /// 收银台服务类
    /// </summary>
    public class CashierService : BaseService
    {
        public CashierService(Config config) : base(config)
        {
        }

        /// <summary>
        /// 查询订单状态
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<OrderQueryResponse> QueryOrderAsync(OrderQueryRequest request)
        {
            return await PostAsync<OrderQueryRequest, OrderQueryResponse>(request, OrderQueryRequest.API_URI);
        }

        /// <summary>
        /// 创建预下单
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<PreOrderResponse> CreatePreOrderAsync(PreOrderRequest request)
        {
            return await PostAsync<PreOrderRequest, PreOrderResponse>(request, PreOrderRequest.API_PREFIX + PreOrderRequest.API_URI);
        }

        /// <summary>
        /// 撤销交易
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<TradeCancelResponse> CancelTradeAsync(TradeCancelRequest request)
        {
            return await PostAsync<TradeCancelRequest, TradeCancelResponse>(request, TradeCancelRequest.API_URI);
        }

        /// <summary>
        /// 退款交易
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<TradeRefundResponse> RefundTradeAsync(TradeRefundRequest request)
        {
            return await PostAsync<TradeRefundRequest, TradeRefundResponse>(request, TradeRefundRequest.API_URI);
        }
    }
} 